import axios from 'axios'
// import { Message, MessageBox } from 'element-ui'
// import store from '../store'
// import { getToken } from '@/utils/auth'

// 创建axios实例
const service = axios.create({
  baseURL: process.env.BASE_API,
  headers: { 'Content-Type': 'application/json;charset=UTF-8' }, 
  withCredentials:true,
  timeout: 15000 // 请求超时时间
})

service.interceptors.request.use(
  config => {
    var user = window.user;
    if (user) {
      const token = window.token;
      
      config.headers['authorization'] = 'Bearer ' + token;
  }
    return config
  },
  error => {
    // Do something with request error
    
    console.log(error) // for debug
    Promise.reject(error)
  }
)
export default service
